﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Text;
using System.Threading.Tasks;
using FxCore.Base;
using FxCore.MapSrc;

namespace FxCore.MapSrc.OpenStreetMap
{
    /// <summary>
    /// OpenStreetMap的标准地图
    /// </summary>
    public class StandardMap : AbstractMapSrc
    {
        public string ChnName => "OpenStreetMap标准地图";

        public string EngName => "OSM_StandardMap";

        public int MaxZoomLevel => 19;

        public int MinZoomLevel => 0;

        private readonly string _urlSchema;

        public StandardMap()
        {
            this._urlSchema = "http://a.tile.openstreetmap.org/zoom/{0}/{1}/{2}.png";
        }

        public FxTile GetTile(int zoomLevel, TilePoint tile)
        {
            string url = this.ParseTileUrl(zoomLevel, tile);
            return FxTile.Empty;
        }

        protected string ParseTileUrl(int zoomLevel, TilePoint tile)
        {
            if (zoomLevel < this.MinZoomLevel || zoomLevel > this.MaxZoomLevel)
            {
                throw new ArgumentOutOfRangeException(nameof(zoomLevel));
            }

            return String.Format(this._urlSchema, zoomLevel, tile.TileX, tile.TileY);
        }
    }
}
